﻿#region 命名空间

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WinnerCMS.BLL;
using WinnerCMS.Common;
using WinnerCMS.Model;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.Task
{
    [Access("266002")]
    public partial class Manage : WebFactory.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.lblPath.Text = "<a href=\"Manage.aspx\">计划任务</a>";

                new TaskManage().BindList(this.GV_List);
            }
        }

        protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var lb = e.Row.Cells[3].Controls[0] as LinkButton;

                if (lb.Text == "1")
                {
                    lb.Text = "<IMG alt=\"启用\" src=\"../Images/success-true.gif\">";
                }
                else
                {
                    lb.Text = "<IMG alt=\"停止\" src=\"../Images/failed-false.gif\">";
                }
            }
        }

        protected void GV_List_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            var bll = new TaskManage();
            var model = bll.GetInfo(this.GV_List.DataKeys[(int) e.CommandArgument].Value.ToString());

            model.IsUsed = !model.IsUsed;

            bll.Add(model);
        }
    }
}